import {createStore} from 'vuex'

export default createStore({
  state: {
    editorRandKey: new Date().getTime(),
    currentMode: 'json',
    modeType: {
      Raw: 'raw',
      Json: 'json'
    },
    redisData: {
      type: '',
      key: '',
      content: ''
    }
  },
  mutations: {
    changeEditorRandKey(state) {
      state.editorRandKey = new Date().getTime() + 1
    },
    changeCurrentMode(state, mode) {
      if (mode === 'json' || mode === 'raw') {
        state.currentMode = mode
      }
    },
    saveRedisData(state, data) {
      state.redisData.type = data.type
      state.redisData.key = data.key
      state.redisData.content = data.content
    }
  },
  actions: {
    asyncChangeEditorRandKey() {
      state.editorRandKey = new Date().getTime() + 1
    }
  },
  modules: {},

})
